import { createRouter, createWebHistory } from 'vue-router';

// 懒加载页面组件
const Home = () => import('../views/Home.vue');
const Login = () => import('../views/Login.vue');
const Register = () => import('../views/Register.vue');
const VideoDetail = () => import('../views/VideoDetail.vue');
const CategoryVideos = () => import('../views/CategoryVideos.vue');

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/video/:id',
    name: 'VideoDetail',
    component: VideoDetail
  },
  {
    path: '/category/:id',
    name: 'CategoryVideos',
    component: CategoryVideos
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

// 导航守卫可以在这里添加
router.beforeEach((to, from, next) => {
  // 可以在这里添加登录检查等逻辑
  next();
});

export default router;